/**
 * 创建日期:2017/11/17 10:14
 * 创建作者:ewjx
 * 修改日期:2017/11/17 10:14
 * 备注信息:公共导航栏组件
 */

import {navData} from './nav.js';

// home主页面导航栏组件
export let HomeNavHtml = function () {
    let element = `<nav 
            class="home-nav width-menu ${window.location.hash.split('/')[1]}-nav">`;
    for (const name in navData) {
        element += `<div class="nav-cs"><p class="nav-name">${name}</p>`;
        navData[name].forEach((value, index, array) => {
            if (array.length / 2 === index) {
                element += '<br>'
            }
            element += `<a class="nav-link" href='#/${Object.keys(value)[0]}'>
                ${Object.values(value)[0]}</a>`;
        });
        element += '</div>';
    }
    return element += '</nav>';
};

// 其他页面的导航栏
export const OtherNavHtml = function () {
    let element = '<div class="other-nav">';
    const navData = ['首页', '城事', '生活', '分类', '社区'];
    navData.forEach((value, index) => {
        element += `<div class='other-link nav-${index}'>
        <a>${value}</a>
        <i class="fa fa-caret-down"></i>
        </div>`;
    });
    document.querySelector('#menu').innerHTML = HomeNavHtml();
    return element += '</div>';
};